// 获取新闻频道和新闻列表
import axios from 'axios'
import {APP_CODE, CHANNEL_API, NEWS_API} from './config'

/**
 * 获取新闻频道列表
 */
export async function getChannelList() {
    let resp = await axios.get(CHANNEL_API, {
        headers: {}
    });
    return resp.data.data;
}

/**
 * 获取新闻列表
 * @param {number} channelId 频道ID
 * @param {number} page 当前页码
 * @param {number} limit 每页数据
 */
export async function getNewsList(channelId = 1, page = 1, limit = 10) {
    let resp = await axios.get(NEWS_API, {
        headers: {
            Authorization: `APPCODE ${APP_CODE}`
        },
        params: {
            channelId,
            page,
            limit,
        }
    });
    return resp.data;
}
